﻿using Gallery.Datas;
using Gallery.Datas.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gallery
{
	/// <summary>
	/// 货币基金收益服务接口。
	/// </summary>
	public class MoneyFundIncomeService : IMoneyFundIncomeService
	{
		/// <summary>
		/// 获取所有货币基金的最新收益。
		/// </summary>
		/// <returns></returns>
		public List<MoneyFundIncome> GetLatestIncomes()
		{
			return MoneyFundIncomeDbService.Instance.GetLatestIncomes();
		}

		/// <summary>
		/// 获取某个货币基金的历史收益。
		/// </summary>
		/// <param name="code">基金代码。</param>
		/// <param name="pageSize">每页记录数。</param>
		/// <param name="pageIndex">获取页索引。</param>
		/// <returns></returns>
		public List<MoneyFundIncome> GetIncomes(string code, int pageSize, int pageIndex)
		{
			var fund = FundService.Instance.GetFund(code);
			if (fund == null) return new List<MoneyFundIncome>();
			return MoneyFundIncomeDbService.Instance.GetIncomes(fund.Id, pageSize, pageIndex);
		}
	}
}
